const CracoLessPlugin = require('craco-less');
const CracoAlias = require('craco-alias');
const path = require('path');
const { theme } = require('antd/lib');
const { convertLegacyToken } = require('@ant-design/compatible/lib');

const { defaultAlgorithm, defaultSeed } = theme;

const mapToken = defaultAlgorithm(defaultSeed);
const v4Token = convertLegacyToken(mapToken);
module.exports = {
    loader: 'less-loader',
    options: {
        lessOptions: {
            modifyVars: v4Token,
        },
    },
    devServer: {
        port: 9001,
        proxy: {
            '/api': {
                target: "https://test.zctgyl.com",
                changeOrigin: true,
                pathRewrite: {
                    "^/api": ""
                },
            }
        },
    },
    webpack: {
        // 配置别名
        alias: {
            "@": path.resolve("src"),
        }
    },
    plugins: [
        {
            plugin: CracoAlias,
            options: {
                source: 'options',
                baseUrl: './',
                aliases: {
                    '@pages': path.resolve(__dirname, 'src/pages'),
                    '@src': path.resolve(__dirname, 'src'),
                },
            },
        },
        {
            plugin: CracoLessPlugin,
            options: {
                lessLoaderOptions: {
                    lessOptions: {
                        modifyVars: { '@primary-color': '#1890ff' },
                        javascriptEnabled: true,
                    },
                },
            },
        },
    ],
};
